define(function(require, exports, module) {
    "use strict";

    if (!String.prototype.format) {
        String.prototype.format = function() {
            var args = arguments;
            return this.replace(/{(\d+)}/g, function(match, number) {
                return typeof args[number] != 'undefined' ? args[number] : match
            })
        }

    }
    if (!String.prototype.trim) {

        String.prototype.trim = function() {
            return this.replace(/^\s*/, "").replace(/\s*$/, "");
        }

    }
    if (!String.prototype.parameters) {

        String.prototype.parameters = function() {
            var result = {};
            var reg = new RegExp('([\\?|&])(.+?)=([^&?]*)', 'ig');
            var arr = reg.exec(this);
            while (arr) {
                result[arr[2]] = arr[3];
                arr = reg.exec(this);
            }
            return result;
        }


    }
    if (!String.prototype.stripTags) {
        //移除html
        String.prototype.stripTags = function() {
            return this.replace(/<\/?[^>]+>/gi, '');
        }

    }
    if (!String.prototype.getNum) {
        //保留数字
        String.prototype.stripTags = function() {
            return this.replace(/[^d]/g, "");
        }

    }
    if (!String.prototype.getEn) {
        // 保留字母
        String.prototype.getEn = function() {
            return this.replace(/[^A-Za-z]/g, "");
        }


    }
    if (!String.prototype.getCn) {
        // 保留中文
        String.prototype.getCn = function() {
            return this.replace(/[^u4e00-u9fa5uf900-ufa2d]/g, "");
        }
    }
    if (!Date.prototype.format) {
        Date.prototype.format = function(format) {
            var date = {
                "M+": this.getMonth() + 1,
                "d+": this.getDate(),
                "h+": this.getHours(),
                "m+": this.getMinutes(),
                "s+": this.getSeconds(),
                "q+": Math.floor((this.getMonth() + 3) / 3),
                "S+": this.getMilliseconds()
            };
            if (/(y+)/i.test(format)) {
                format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
            }
            for (var k in date) {
                if (new RegExp("(" + k + ")").test(format)) {
                    format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? date[k] : ("00" + date[k]).substr(("" + date[k]).length));
                }
            }
            return format;
        }


    };

    window.StringBuilder = function(str) {
        this.tmp = new Array();
    }
    StringBuilder.prototype.Append = function(value) {
        this.tmp.push(value);
        return this;
    }
    StringBuilder.prototype.Clear = function() {
        tmp.length = 1;
    }
    StringBuilder.prototype.toString = function() {
        return this.tmp.join('');
    }


})
